﻿namespace InDepthDemo.Chapter01.CSharp4
{
    internal class Product
    {
        public string Name { get; private set; }
        public decimal Price { get; private set; }

        public Product(string name, decimal price)
        {
            Name = name;
            Price = price;
        }

        Product() { }

        public static List<Product> GetSampleProducts()
        {
            List<Product> list = new()
            {
                // 这里用的是 Product() 这个无参的构造函数。
                new Product { Name = "West Side Story", Price = 9.99m },
                new Product { Name = "Assassins", Price = 14.99m },
                new Product { Name = "Frogs", Price = 13.99m },
                new Product("Sweeney Todd", 10.99m)
            };
            return list;
        }

        public override string ToString()
        {
            return string.Format("{0}: {1}", Name, Price);
        }
    }
}
